package com.ddl.kafka.config.consumer;

import com.ddl.kafka.config.dto.MessageData;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

import lombok.extern.slf4j.Slf4j;

@Component
@Slf4j
public class Demo01Consumer {

	@Value("${msgQueue.topic}")
	private String topic;

	@KafkaListener(topics = "${msgQueue.topic}",
			groupId = "demo01-consumer-group-" + "${msgQueue.topic}")
	public void onMessage(MessageData message) {
		log.info("[onMessage][线程编号:{} 消息内容：{}]", Thread.currentThread().getId(), message);
	}

	@KafkaListener(topics = "${msgQueue.topic}",
			groupId = "demo01-A-consumer-group-" + "${msgQueue.topic}")
	public void onMessage(String record) {
		log.info("[onMessage][线程编号:{} 消息内容：{}]", Thread.currentThread().getId(), record);
	}

}
